package com.one.common.manager.imageloader;

import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.widget.ImageView;

import java.io.File;

/**
 * @Description: 图片加载接口
 * @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
 * @date: 2016-12-19 15:04
 */
public interface ILoader {
    void init(Context context);

    void loadNet(ImageView target, String url);

    void loadNet(ImageView target, String url, Options options);

    void loadResource(ImageView target, int resId, Options options);

    void loadAssets(ImageView target, String assetName, Options options);

    void loadFile(ImageView target, File file, Options options);

    void loadUri(ImageView target, Uri uri, Options options);

    void loadBitmap(ImageView target, Bitmap bitmap, Options options);

    void clearMemoryCache(Context context);

    void clearDiskCache(Context context);

    class Options {

        public static final int RES_NONE = -1;
        public int loadingResId = RES_NONE;//加载中的资源id
        public int loadErrorResId = RES_NONE;//加载失败的资源id

        public int WIDTH = RES_NONE;// 图片宽度
        public int HEIGHT = RES_NONE;// 图片高度

        public boolean isCircle = false; // 是否圆形
        public boolean centerCrop = false; // 是否居中裁剪

        public int round = 0;// 圆角大小

        public boolean isMask = false; // 是否有遮罩

        public boolean isBlur = false; // 是否有高斯模糊

        public static Options defaultOptions() {
            return new Options(ILoader.Options.RES_NONE, ILoader.Options.RES_NONE);
        }
        public static Options circleOptions() {
            return new Options(ILoader.Options.RES_NONE, ILoader.Options.RES_NONE,true);
        }

        public static Options roundOptions(int round) {
            return new Options(ILoader.Options.RES_NONE, ILoader.Options.RES_NONE, round);
        }

        public static Options maskRoundOptions(int round, boolean isMask) {
            return new Options(ILoader.Options.RES_NONE, ILoader.Options.RES_NONE,round,isMask);
        }


        public Options(int loadingResId, int loadErrorResId) {
            this.loadingResId = loadingResId;
            this.loadErrorResId = loadErrorResId;
        }

        public Options(int loadingResId, int loadErrorResId, int WIDTH, int HEIGHT) {
            this.loadingResId = loadingResId;
            this.loadErrorResId = loadErrorResId;
            this.WIDTH = WIDTH;
            this.HEIGHT = HEIGHT;
        }

        public Options(int loadingResId, int loadErrorResId, boolean isCircle) {
            this.loadingResId = loadingResId;
            this.loadErrorResId = loadErrorResId;
            this.isCircle = isCircle;
        }

        public Options(int loadingResId, int loadErrorResId, int round) {
            this.loadingResId = loadingResId;
            this.loadErrorResId = loadErrorResId;
            this.round = round;
        }

        public Options(int loadingResId, int loadErrorResId, int round, boolean isMask) {
            this.loadingResId = loadingResId;
            this.loadErrorResId = loadErrorResId;
            this.round = round;
            this.isMask = isMask;
        }

        public Options(boolean isCircle) {
            this.isCircle = isCircle;
        }

        public int getRound() {
            return round;
        }

        public boolean isMask() {
            return isMask;
        }

        public void setMask(boolean mask) {
            isMask = mask;
        }

        public boolean isCenterCrop() {
            return centerCrop;
        }

        public boolean isBlur() {
            return isBlur;
        }

        public void setBlur(boolean blur) {
            isBlur = blur;
        }

        public void setCenterCrop(boolean centerCrop) {
            this.centerCrop = centerCrop;
        }


    }
}
